//
//  ByFootBallTitleView.m
//  caipiao_ios
//
//  Created by mc on 2018/7/20.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByFootBallTitleView.h"
#import "ByDottedLineView.h"
@implementation ByFootBallTitleView

- (id)init{
    self = [super init];
    if (self) {
        
        UIImageView *danguanView = [[UIImageView alloc] init];
        [self addSubview:danguanView];
        [danguanView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.top.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(35, 35));
        }];
        danguanView.image = [UIImage imageNamed:@"danguan单关"];
        danguanView.hidden = YES;
        self.danguanView = danguanView;
        
        
        
        UIView *topView = [[UIView alloc] init];
        [self addSubview:topView];
        [topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(self).offset(0);
            make.right.equalTo(self).offset(-20);
            make.height.mas_equalTo(@42);
        }];
        
        UILabel *sessionLabel = [[UILabel alloc] init];
        [topView addSubview:sessionLabel];
        [sessionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(topView).offset(0);
            make.centerY.equalTo(topView).offset(0);
            make.size.mas_equalTo(CGSizeMake(100, 20));
        }];
        sessionLabel.text = @"周二001";
        sessionLabel.textColor = [UIColor blackColor];
        sessionLabel.textAlignment = NSTextAlignmentCenter;
        sessionLabel.font = FONT(14);
        
        
        UILabel *timesLabel = [[UILabel alloc] init];
        [topView addSubview:timesLabel];
        [timesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(topView).offset(0);
            make.centerY.equalTo(topView).offset(0);
            make.left.equalTo(sessionLabel.mas_right).offset(10);
        }];
        timesLabel.text = @"02/07 00:50截止";
        timesLabel.textColor = [UIColor lightGrayColor];
        timesLabel.textAlignment = NSTextAlignmentRight;
        timesLabel.font = FONT(12);
        
        
        UILabel *titleLabel = [[UILabel alloc] init];
        [topView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(topView).offset(0);
            make.centerY.equalTo(topView).offset(0);
            make.height.mas_equalTo(@15);
            make.right.equalTo(sessionLabel.mas_left).offset(-10);
        }];
        titleLabel.text = @"世界杯";
        titleLabel.font = FONT(14);
        titleLabel.textColor = [UIColor lightGrayColor];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        
        
        
        
        UIView *bottomView = [[UIView alloc] init];
        [self addSubview:bottomView];
        [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.right.equalTo(self).offset(0);
            make.height.mas_equalTo(@42);;
        }];
        
        
        UILabel *vsLabel = [[UILabel alloc] init];
        [bottomView addSubview:vsLabel];
        [vsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(bottomView).offset(0);
            make.centerY.equalTo(bottomView).offset(0);
            make.size.mas_equalTo(CGSizeMake(50, 20));
        }];
        vsLabel.text = @"vs";
        vsLabel.textColor = [UIColor blackColor];
        vsLabel.textAlignment = NSTextAlignmentCenter;
        vsLabel.font = FONT(14);
        
        
        UILabel *teamLabel1 = [[UILabel alloc] init];
        [bottomView addSubview:teamLabel1];
        [teamLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
            //make.left.equalTo(bottomView).offset(0);
            make.size.mas_equalTo(CGSizeMake(70, 20));
            make.centerY.equalTo(bottomView).offset(0);
            make.right.equalTo(vsLabel.mas_left).offset(-10);
        }];
        teamLabel1.text = @"哈马比";
        teamLabel1.textColor = [UIColor blackColor];
        teamLabel1.textAlignment = NSTextAlignmentLeft;
        teamLabel1.font = FONT(14);
        
        
        UIImageView *leftView = [[UIImageView alloc] init];
        [bottomView addSubview:leftView];
        [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(teamLabel1.mas_left).offset(-5);
            make.centerY.equalTo(bottomView).offset(0);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        self.leftView = leftView;
        
        
        UIImageView *rightView = [[UIImageView alloc] init];
        [bottomView addSubview:rightView];
        [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(vsLabel.mas_right).offset(20);
            make.centerY.equalTo(bottomView).offset(0);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        self.rightView = rightView;
        
        
        UILabel *teamLabel2 = [[UILabel alloc] init];
        [bottomView addSubview:teamLabel2];
        [teamLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bottomView).offset(0);
            make.centerY.equalTo(bottomView).offset(0);
            make.left.equalTo(rightView.mas_right).offset(10);
        }];
        teamLabel2.text = @"鄂尔多斯";
        teamLabel2.textColor = [UIColor blackColor];
        teamLabel2.textAlignment = NSTextAlignmentLeft;
        teamLabel2.font = FONT(14);
        
        
        ByDottedLineView *line = [[ByDottedLineView alloc] init];
        line.direction = DottedLineViewDirectionHorizontalFromRight;
        line.lineColor = BY_LINE_COLOR;
        line.lengthPattern = @[@4, @3];
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.right.equalTo(self).offset(0);
            make.top.equalTo(topView.mas_bottom).offset(0);
            make.height.mas_equalTo(@1);
        }];
        
        self.titleLabel = titleLabel;
        self.sessionLabel = sessionLabel;
        self.timesLabel = timesLabel;
        self.teamLabel1 = teamLabel1;
        self.teamLabel2 = teamLabel2;
      
        
    }
    return self;
}

- (void)setNetModel:(ByNetModel *)netModel{
    
    _netModel = netModel;
    
    if (_isBasketBall) {
        self.teamLabel1.text = _netModel.a_cn_abbr;
        self.teamLabel2.text = _netModel.h_cn_abbr;
        self.leftView.image = [UIImage imageNamed:@"kedui客队"];
        self.rightView.image = [UIImage imageNamed:@"zhudui主队"];
        
    } else {
        self.teamLabel1.text = _netModel.h_cn_abbr;
        self.teamLabel2.text = _netModel.a_cn_abbr;
        
        self.leftView.image = [UIImage imageNamed:@"zhudui主队"];
        self.rightView.image = [UIImage imageNamed:@"kedui客队"];
    }
    
   
    self.sessionLabel.text = _netModel.num;
    self.titleLabel.text = _netModel.l_cn_abbr;
    self.timesLabel.text = [NSString stringWithFormat:@"%@截止", [_netModel.time substringToIndex:5]];
}

- (void)setIsBasketBall:(BOOL)isBasketBall{
    _isBasketBall = isBasketBall;
}

@end
